package DivideyVenceras;

import java.util.ArrayList;

public class Cosas {
	
	public static int [] aleatorizar( int num,int [] matriz){
		for(int i=0;i<num;i++)
			matriz[i]=(int)(Math.random()*(70-15)+15);
		return matriz;	
	}


	
//QUICKSORT
	public static void intercambia(int[] v, int pos1, int pos2){
		int aux=v[pos1];
		v[pos1]=v[pos2];
		v[pos2]=aux;
	}
	public static void quicksort(int[] v, int li, int ls){
		if (li<ls){
			int pos=divide(v,li,ls);
			quicksort(v, li, pos-1);
			quicksort(v, pos+1, ls);
		}
	}
	public static int divide(int[] v, int li, int ls){
		int pivote=v[li];
		int izq=li+1; int der=ls;
		while(izq<der && v[izq]<=pivote ) izq++;
		while (v[der]>pivote) der--;
		while (izq<der){
			intercambia(v,izq,der);
			do{izq++;}while(v[izq]<=pivote);
			do{der--;}while(v[der]>pivote);
		}
		intercambia(v,li,der);
		return der;
	}
}

